import 'package:flutter/material.dart';

import '../models/message.dart';



class ChatScreen extends StatelessWidget {
  const ChatScreen({super.key});

  @override
  Widget build(BuildContext context) {
    final List<Message> messages = [
      Message(content: "Hello", isUser: true, timestamp: DateTime.now()),
      Message(content: "How are you?", isUser: false, timestamp: DateTime.now()),
      Message(
          content: "Fine,Thank you. And you?",
          isUser: true,
          timestamp: DateTime.now()),
      Message(content: "I am fine.", isUser: false, timestamp: DateTime.now()),
    ];

    return Scaffold(
      appBar: AppBar(
        title: const Text('data'),
      ),
      body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Column(
            children: [
              Expanded(
                  child: ListView.separated(
                itemBuilder: (context, index) {
                  return Row(
                    children: [
                      // 圆形
                      CircleAvatar(
                        backgroundColor: messages[index].isUser ? Colors.blue : Colors.grey,
                        child: Text(
                          messages[index].isUser ? 'A' : 'GPT',
                        )),
                      const SizedBox(
                        width: 8,
                      ),
                      Text(messages[index].content),
                    ],
                  );
                }, itemCount: messages.length,
                separatorBuilder: (context, index) => const Divider(
                  height: 16,
                ),
              )),
              // 输入框
              TextField(
                  decoration: InputDecoration(
                      hintText: 'Type a message', // 显示在输入框内的提示文字
                      suffixIcon: IconButton(
                        onPressed: () {},
                        icon: const Icon(
                          Icons.send,
                        ),
                      )))
            ],
          )),
    );
  }
}
